 /**
  * Created by ex-luandebiao001 on 2015/2/11.
 */
;
(function(){
    'use strict';
   
    var app = angular.module('fwa.mainApp');
    
    app.controller('performanceRankingCtrl',['$scope','$http','Modal','BaseURL',function($scope,$http,Modal,baseURL){
        $scope.form = {};
        //分页配置
        $scope.current = {
                            totalCount: 0,
                            currentPage:0,
                            limit:10
                         };
        
        $scope.columns = [
                          {label:"排名",map:"RK",width:"8%",cellTemplate:'{{data.RK}}'},
                          {label:"机构",map:"HOSPITAL",width:"16%",cellTemplate:'<a  ng:bind="data.HOSPITAL" '+
                              'ui-sref="performanceRanking.performanceData({kpiTime:data.KPITIME,grade:data.GRADE,hospitalName:data.HOSPITAL,hospitalCode:data.CODE,regionCode:data.REGION})"></a>'},
                          {label:"机构等级",map:"GRADE",width:"7%"},
                          {label:"统计时间",map:"KPITIME",width:"7%"},
                          {label:"总分数",map:"IND01",width:"6%"},
                          {label:"住院费用",map:"IND010101",width:"7%"},
                          {label:"门诊费用",map:"IND010102",width:"7%"},
                          {label:"FWA审核",map:"IND010103",width:"7%"},
                          {label:"个人负担",map:"IND010201",width:"7%"},
                          {label:"医保政策依从性",map:"IND010301",width:"12%"},
                          {label:"医保审核管理",map:"IND010302",width:"10%"},
                          {label:"信息化",map:"IND010401",width:"6%"}
                          ];
        
        $scope.hospitalLevel = [{key:"1",value:"一级"},
                                {key:"2",value:"二级"},
                                {key:"3",value:"三级"}
                               ];
        
        //查询
        $scope.onSubmit = function() {
            $scope.current.currentPage = 1;
            query();
        }
    
        //重置
        $scope.onReset = function() {
            $scope.form.grade ={key:null,value:null};
            $scope.form.date = {start:null,end:null};
        }
        
        //分页监听
        $scope.$on('pageTool.skipPage',function(e,v){
           
            query(v);
        });
        
        //查询
        $scope.detail = function() {
            $state.go('performanceRanking.performanceData',{
                type:0
            });
        }
        
        function query() {
            var startDate = '', endDate = '',grade="";
            
            if ($scope.form.date && $scope.form.date.start) {
                startDate = $scope.form.date.start;
            }
            
            if ($scope.form.date && $scope.form.date.end) {
                endDate = $scope.form.date.end;
            }
            if ($scope.form.grade) {
                grade = $scope.form.grade;
            }
            var params = {
                        page : $scope.current.currentPage,
                        limit : $scope.current.limit,
                        grade : grade,
                        startDate : startDate,
                        endDate : endDate
                    };
            
            $http({
                method: "get",
                url:baseURL+'assessment/getRankingInfos.do',
                params:params
            }).success(function(res){
                $scope.tableData = res.root;
                $scope.current.totalCount = res.total;
            }).error(function(e){
                Modal.alert(e.msg);
            });
        }
    }]);
})();